import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import { TableColumn } from '@/types/table'
// 表单校验
export const rules = reactive({
  title: [{ required: true, message: '账号名称不能为空', trigger: 'blur' }],
  rutime: [{ required: true, message: '刷新renewtoken时间不能为空', trigger: 'blur' }],
  refreshRemark: [{ required: true, message: '刷新备注不能为空', trigger: 'blur' }],
  status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
  sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }]
})
//复杂配置参照文档修改
const crudSchemas = reactive<CrudSchema[]>([
  {
    label: 'ID',
    field: 'id',
    isSearch: false,
    isColumnHidden: false
  },
  {
    label: '平台类型',
    field: 'platformType',
    isSearch: true,
    isColumnHidden: false,
    dictType: DICT_TYPE.THIRDPART_PLATFORM_TYPE,
    dictClass: 'number',
    search: {
      componentProps: {
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '账号名称',
    field: 'title',
    isSearch: true,
    isColumnHidden: false,
    search: {
      componentProps: {
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '头像',
    field: 'avatar',
    isSearch: false,
    isColumnHidden: false
  },
  {
    label: '类型',
    field: 'type',
    isSearch: true,
    isColumnHidden: false,
    dictType: DICT_TYPE.THIRDPART_PLATFORM_ACCOUNT_TYPE,
    dictClass: 'number',
    search: {
      componentProps: {
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '过期时间',
    field: 'expiresIn',
    isSearch: false,
    isColumnHidden: false
  },
  {
    label: '账号状态',
    field: 'state',
    isSearch: true,
    isColumnHidden: false,
    search: {
      componentProps: {
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '账号openid',
    field: 'openId',
    isSearch: false,
    isColumnHidden: true
  },
  {
    label: '账号unionid',
    field: 'unionId',
    isSearch: false,
    isColumnHidden: true
  },
  {
    label: '刷新过期时间',
    field: 'refreshExpiresIn',
    isSearch: false,
    isColumnHidden: true
  },
  {
    label: '刷新renewtoken时间',
    field: 'rutime',
    isSearch: false,
    isColumnHidden: true,
    formatter: dateFormatter
  },
  {
    label: '刷新备注',
    field: 'refreshRemark',
    isSearch: false,
    isColumnHidden: false
  },
  {
    label: '备注名称',
    field: 'remark',
    isSearch: false,
    isColumnHidden: true
  },
  {
    label: '状态',
    field: 'status',
    isSearch: true,
    isColumnHidden: false,
    dictType: DICT_TYPE.COMMON_STATUS,
    dictClass: 'number',
    search: {
      componentProps: {
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '创建时间',
    field: 'createTime',
    isSearch: true,
    isColumnHidden: false,
    formatter: dateFormatter,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')],
        style: {
          width: '240px'
        }
      }
    }
  },
  {
    label: '更新时间',
    field: 'updateTime',
    isSearch: false,
    isColumnHidden: true,
    formatter: dateFormatter
  },
  {
    label: '排序',
    field: 'sort',
    isSearch: false,
    isColumnHidden: false
  },
  {
    label: '操作',
    field: 'action',
    isForm: false
  }
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
